<template>
    <el-tooltip :content="config.tooltip" :placement="config.placement" :effect="config.effect" v-if="config.tooltip">
        <el-button @click="emitClick"
            :type="config.type || 'primary'" 
            :size="config.size || 'default'"
            :icon="config.icon || ''" 
            :plain="config.isPlain || false" 
            :text="config.isText || false"
            :link="config.isLink || false" 
            :disabled="config.isDisabled || false" 
            :round="config.isRound || false"
            :circle="config.isCircle || false" 
            :loading="config.isLoading || false" 
            :autofocus="config.isAutofocus || false"
            :auto-insert-space="config.isAutoInsertSpace || false" 
            :native-type="config.nativeType || 'button'"
            :href="config.href || ''" 
            :target="config.target || '_self'" 
            :rel="config.rel || ''"
            :style="config.style || ''"
            >
            {{ label }}
        </el-button>
    </el-tooltip>
    <el-button v-else
            :type="config.type || 'primary'" 
            :size="config.size || 'default'"
            :icon="config.icon || ''" 
            :plain="config.isPlain || false" 
            :text="config.isText || false"
            :link="config.isLink || false" 
            :disabled="config.isDisabled || false" 
            :round="config.isRound || false"
            :circle="config.isCircle || false" 
            :loading="config.isLoading || false" 
            :autofocus="config.isAutofocus || false"
            :auto-insert-space="config.isAutoInsertSpace || false" 
            :native-type="config.nativeType || 'button'"
            :href="config.href || ''" 
            :target="config.target || '_self'" 
            :rel="config.rel || ''"
            :style="config.style || ''"
            >
            {{ label }}
        </el-button>
    
  </template>
  
  <script>
    export default {
        name: "v3-button",
        props: {
            config: {
                type: Object,
                default: () => {}
            }
        },
        setup(props, { emit }) {
            const { config } = props
            const label = config.label
            const emitClick = () => {
                console.log('v3-button--emitClick--', config)
                emit('click', config)
            }
            return {
                label, emitClick
            }
        }
    }
  </script>
  <style>
    .el-button {
        line-height: initial;
    }
  </style>